package com.example.shop_car_2208.fragment

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.launcher.ARouter
import com.example.shop_car_2208.R
import com.example.shop_car_2208.adapter.PayAdapter
import com.example.shop_car_2208.databinding.FragmentPayedBinding
import com.example.shop_car_2208.db.MyDBUtils
import com.example.shop_car_2208.mvvm.BaseViewFragment


class PayedFragment : BaseViewFragment<FragmentPayedBinding>() {
    lateinit var payAdapter: PayAdapter
    override fun initData() {

    }

    override fun initView() {
        payAdapter = PayAdapter()
        binding.rvPaying.adapter = payAdapter
        binding.rvPaying.layoutManager = LinearLayoutManager(context)
        val data = MyDBUtils.getDB().getOrderDao().queryStatus(2)
        payAdapter.data.clear()
        payAdapter.data.addAll(data)
        payAdapter.notifyDataSetChanged()
        //点击去评价跳转到评价界面
        payAdapter.addChildClickViewIds(R.id.comment)
        payAdapter.setOnItemChildClickListener { adapter, view, position ->
            when(view.id){
                R.id.comment->{
                    ARouter.getInstance().build("/app/comment").navigation()
                }
            }
        }
    }

    override fun getLayout(): Int {
        return R.layout.fragment_payed
    }

}